﻿<%@ Page Language="C#" MasterPageFile="~/MainMaster.Master" AutoEventWireup="true"
    CodeBehind="OrglistProductQuote.aspx.cs" Inherits="Mang24k99.Web.ProductQuote.OrglistProductQuote"
    Title="产品报价" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        function TextClear(oEvent,defultText)
        {  
            //如果当前值为默认值，则清空 
            var obj=oEvent.srcElement ? oEvent.srcElement : oEvent.target;
            with(obj) 
            if(value==defultText) value="" 
        }
        function TextRes(oEvent,defultText)
        { 
             //如果值为空，则赋默认值
            var obj=oEvent.srcElement ? oEvent.srcElement : oEvent.target;
            with(obj) 
            if(value=="") value=defultText 
        }
        
        //只能输入数字和小数点
          function verify(obj)
          {
              if(!(obj.keyCode>=48 && obj.keyCode<=57) && !(obj.keyCode==46))
              {
                  obj.returnValue = false;
              } 
          }
          //获取url参数
          Request = {
                QueryString : function(item){
                var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
                return svalue ? svalue[1] : svalue;
                }
            }
          //通过单价和重量计算总价
          function countPrice(obj)
          {
               var goldType=document.getElementById('<%=ddlGoldType.ClientID%>');
               var selectType;
               for(var i=0;i<goldType.options.length;i++)
               {
                    if(goldType.options[i].selected==true)
                    {
                        selectType=goldType.options[i];
                    }
               }
               var productType=Request.QueryString("procduct_type") ;
               var patrn=/^[0-9]+[.]?[0-9]+$|^\d+$/; 
               if((selectType.value=="30204"||selectType.value=="30207") && productType=="2") 
               {   
                   var priceChange=$(obj.parentNode.parentNode.cells[6]).find("input");
                   var totalPrice=$(obj.parentNode.parentNode.cells[8]).find("input");
                   var lastSalePrice=$(obj.parentNode.parentNode.cells[9]).find("input");
                   var saleprice=obj;
                   var weight=$(obj.parentNode.parentNode.cells[3]).find("span");
                   if($(saleprice).val()=="")
                   {
                        alert("单价不能为空！");
                        return;
                   }
                   if (!patrn.exec($(saleprice).val()))
                   {
                        alert("输入格式不对，请输入正确的单价！");
                        return;
                   }
                   if($(saleprice).val()>999999)
                   {
                        alert("输入数字过大，请将数字整数位限制在6位以内！");
                        return;
                   }
                   if(!patrn.exec($(weight).text()))
                   {
                        alert("单位格式不对，请检查！");
                        return;
                   }
                    var val=($(saleprice).val()*$(weight).text()).toFixed(2);
                    $(totalPrice).val(val);
                    val=($(saleprice).val()-$(lastSalePrice).val()).toFixed(4);
                    $(priceChange).val(val);
               } 
               if((selectType.value=="30204"||selectType.value=="30205"||selectType.value=="30206") && productType=="1") 
               {
                   var totalPrice=$(obj.parentNode.parentNode.cells[6]).find("input");
                   var saleprice=obj;
                   var weight=$(obj.parentNode.parentNode.cells[3]).find("span");
                   if($(saleprice).val()!="" && $(saleprice).val()!="--")
                   {
                           if (!patrn.exec($(saleprice).val()))
                           {
                                alert("输入格式不对，请输入正确的单价！");
                                return;
                           }
                           if($(saleprice).val()>999999)
                           {
                                alert("输入数字过大，请将数字整数位限制在6位以内！");
                                return;
                           }
                           if(!patrn.exec($(weight).text()))
                           {
                                alert("单位格式不对，请检查！");
                                return;
                           }
                        var val=($(saleprice).val()*$(weight).text()).toFixed(2);
                        $(totalPrice).val(val);
                   }
                   else
                   {
                        $(totalPrice).val("");
                   }
               }
          }
    </script>

    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="34px" align="center"
        background="../Images/bg1.jpg">
        <tr>
            <td>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
            <td>
                <a class="col" href="GoldBreed.aspx?procduct_type=<%=product_type %>">金品品种维护</a>
            </td>
            <td>
                <a class="col" href="OrglistProduct.aspx?procduct_type=<%=product_type %>">机构经营产品维护</a>
            </td>
            <td>
                <a class="col_on" href="OrglistProductQuote.aspx?procduct_type=<%=product_type %>">产品报价</a>
            </td>
            <td>
                <a id="sort" runat="server" class="col" href="OrglistProductSort.aspx?procduct_type=2">
                    首页排序</a>
            </td>
        </tr>
    </table>
    <table border="1" cellpadding="0" cellspacing="0" bordercolor="#BED6A6" style="border-collapse: collapse">
        <tr>
            <td class="tb_title1">
                机构名称
            </td>
            <td class="tb_txt1">
                <asp:DropDownList ID="ddlOrglist" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlOrglist_SelectedIndexChanged">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="tb_title1">
                金品大类
            </td>
            <td class="tb_txt1">
                <asp:DropDownList ID="ddlGoldType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlGoldType_SelectedIndexChanged">
                </asp:DropDownList>
            </td>
        </tr>
    </table>
    <asp:Panel ID="Panel1" runat="server">
        <div>
            <asp:GridView ID="grdList" runat="server" Width="100%" AutoGenerateColumns="False"
                OnDataBinding="grdList_DataBinding" OnPreRender="grdList_PreRender" EmptyDataText="数据为空！">
                <HeaderStyle CssClass="tb_title2" />
                <RowStyle CssClass="tb_txt2" />
                <Columns>
                    <asp:TemplateField HeaderText="序号" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <%#Container.DataItemIndex+1%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="ProcductNO" HeaderText="主键" HeaderStyle-CssClass="hidden"
                        ControlStyle-CssClass="hidden" ItemStyle-CssClass="hidden" />
                    <asp:TemplateField HeaderText="金品名称" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:Label ID="lbName" runat="server" Text='<%#Eval("MKtGoldGoldbreed.BreedName")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="重量" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:Label ID="lbWeight" runat="server" Text='<%#Eval("MEASUREMENT")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="规格" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:Label ID="lbUnit" runat="server" Text='<%#Eval("MKtCommCodelist.CODE_CNAME")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="卖出价" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:TextBox ID="txtSalePrice" runat="server" Text='<%#Change(1,(decimal)Eval("MKtGoldSaleprice.SalePrice"))%>'
                                onfocus="TextClear(event,'--')" onblur="countPrice(this)" onkeypress="return verify(event)"
                                MaxLength="9" Width="100px"></asp:TextBox>元
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="买入价" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:TextBox ID="txtBuyPrice" runat="server" Text='<%#Change(1,(decimal)Eval("MKtGoldSaleprice.BuyPrice"))%>'
                                onfocus="TextClear(event,'--')" onkeypress="return verify(event)" MaxLength="11"
                                Width="100px"></asp:TextBox>元
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="涨跌" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:TextBox ID="txtPriceChange" runat="server" Text='<%#Change(2,(decimal)Eval("MKtGoldSaleprice.PriceChange"))%>'
                               Width="100px"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="买卖手续费" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:TextBox ID="txtChargeFree" runat="server" Text='<%#Eval("MKtGoldSaleprice.ChargeFee")%>'
                                MaxLength="50"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="总价" ItemStyle-Wrap="false">
                        <ItemTemplate>
                            <asp:TextBox ID="txtTotalPrice" runat="server" Text='<%#Change(1,(decimal)Eval("MKtGoldSaleprice.TotalPrice"))%>'></asp:TextBox>元
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="上次卖出价" HeaderStyle-CssClass="hidden">
                        <ItemTemplate>
                            <asp:TextBox ID="txtLastSalePrice" runat="server" Text='<%#Eval("MKtGoldSaleprice.LastsalePrice")%>'
                                onkeypress="return verify(event)"  ControlStyle-CssClass="hidden"
                                ItemStyle-CssClass="hidden"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server">
        <table border="0" cellpadding="0" cellspacing="0" width="50%" align="center">
            <tr>
                <td align="center">
                    <asp:Button ID="btnOK" CssClass="form_btn" runat="server" Text="确定" OnClick="btnOK_Click" />
                </td>
                <td align="center">
                    &nbsp;
                </td>
                <td align="center">
                    <asp:Button ID="btnCancel" CssClass="form_btn" runat="server" Text="取消" OnClientClick="return confirm('未保存的数据将丢失，确定取消吗？')"
                        OnClick="btnCancel_Click" />
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
